import AutoImport from 'unplugin-auto-import/vite' //自动引入ref,reactive等等等
// 配置ElementPlus按需加载
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export const autoImport = () => {
  return AutoImport({
    // 目标文件
    include: [
      /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
      /\.vue$/,
      /\.vue\?vue/, // .vue
      /\.md$/ // .md
    ],
    // dirs: ['src/utils/**', 'src/store/**'],
    imports: ['vue', 'vue-router', 'pinia', 'vue-i18n'],
    // eslint报错解决
    eslintrc: {
      enabled: false, // Default `false`
      filepath: '../../.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
      globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
    },
    dts: 'src/types/auto-import.d.ts', //生成全局引入的文件
    resolvers: [ElementPlusResolver({ importStyle: 'sass' })]
  })
}

export const comImport = (isBuild: boolean) => {
  // 生产环境运用unplugin-vue-components
  // 开发环境完整引入element-plus
  return isBuild
    ? Components({
        resolvers: [ElementPlusResolver({ importStyle: 'sass' })],
        dts: 'src/types/components.d.ts'
      })
    : Components({
        dts: 'src/types/components.d.ts'
      })
}
